<template>
    <van-tabbar v-model="active" style="background-color: #FFc300">
        <van-tabbar-item
                icon="home-o"
                to="/commodity">
            首页
        </van-tabbar-item>
        <van-tabbar-item
                icon="shopping-cart-o"
                to="/shopping"
                :badge="shoppingNumber">
            购物车
        </van-tabbar-item>
        <van-tabbar-item
                icon="manager-o"
                to=/person>
            我的
        </van-tabbar-item>
    </van-tabbar>
</template>

<script>
export default {
        name: "BottomBar",
        data(){
            return{
                active:0
            }
        },
        computed:{
         //计算购物车数量
         shoppingNumber(){
             return this.$store.state.shoppingTotal;
         }

        },
        methods:{
            updatePresentIndex(indexPresent){
                this.active=indexPresent
            }
        },
        created() {
            this.$bus.$on("updatePresentIndex",this.updatePresentIndex)
            this.$router.push("/commodity")
        }
    }
</script>

<style scoped>

</style>
